//Thursday, December 17 2009
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

class SpidersOnTheGrid
{
public:
	int find(vector <string> A)
	{
		int N = A.size();
		int M = A[0].size();
		vector<vector<int> > v(N+2, vector<int>(M+2, 1));
		for(int i=0; i<A.size(); i++)
		{
			for(int j=0; j<A[i].size(); j++)
			{
				v[i+1][j+1]--;
				if(A[i][j] == 'E')
				{
// 					v[i+1][j+1]--;
					v[i+1][j+2]++;
				}
				else if(A[i][j] == 'W')
				{
					v[i+1][j]++;
				}
				else if(A[i][j] == 'N')
				{
					v[i][j+1]++;
				}
				else if(A[i][j] == 'S')
				{
					v[i+2][j+1]++;
				}
			}
		}
		int ret = 0;
		for(int i=1; i<=N; i++)
			for(int j=1; j<=M; j++)
				if(v[i][j] == 0)
					ret++;
		return ret;
	}
};
